package com.example.springboot01.event;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author keyer
 * @Description : 可以对同一个抛出事件做出不同的反应；
 * Created by cyd on 2021-06-03 13:56:25
 */
@Component
public class DemoListener2 implements ApplicationListener<DemoEvent> {

    @Override
    public void onApplicationEvent(DemoEvent event) {
        String msg = event.getMsg();
        Date date = event.getDate();
        System.out.println("DemoListener2收到了消息：" + msg + "," + date);
        // 可以调其他的方法
    }
}
